//子集问题的哈希去重
class Solution {
public:
    vector<int>tmp;
    vector<vector<int>>res;
    vector<vector<int>> subsetsWithDup(vector<int>& nums) 
    {
        sort(nums.begin(),nums.end());
        dfs(nums,0);
        return res;
    }
    void dfs(vector<int>& nums,int index)
    {
        res.push_back(tmp);
        unordered_set<int>hash;
        for(int i=index;i<nums.size();i++)
        {
            if(hash.find(nums[i])!=hash.end())
            {
                continue;
            }
            tmp.push_back(nums[i]);
            hash.insert(nums[i]);
            dfs(nums,i+1);
            tmp.pop_back();
            //hash只记录当前层是否出现过相同的值
            //每进入一次递归 就会出现一个新的hash
            //这个hash只用来筛选 for遍历中是否出现重复值
        }
    }
};